package io.github.maojian.bianrysearch;

import org.junit.Test;

/**
 * @Auther: jian.mao
 * @Date: 2022-06-28 15:15
 * @Description: https://leetcode.cn/problems/arranging-coins/
 */
public class Q441 {
    public int arrangeCoins(int n) {
        int sum = 0, i = 0;
        while (sum <= n) {
            i++;
            sum += i;
        }
        if (sum == n) return i;
        return i - 1;
//        return (int) ((Math.sqrt((long) 8 * n + 1) - 1) / 2);
    }

    @Test
    public void test() {
        System.out.println(arrangeCoins(5));
    }
}
